﻿Public Class NetworkHelper

    ''' <summary>
    ''' This function is used to check if the computer is connected with the internet
    ''' </summary>
    ''' <param name="URLToCheck">optional variable for the URL</param>
    ''' <returns>true if connected. </returns>
    ''' <remarks></remarks>
    Public Shared Function IsConnectedToInternet(Optional ByVal URLToCheck As String = "http://www.yahoo.com") As Boolean
        Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(URLToCheck)
        Dim resp As System.Net.WebResponse
        Try
            resp = req.GetResponse()
            resp.Close()
            resp = Nothing
            req = Nothing
            Return True
        Catch ex As Exception
            req = Nothing
            Return False
        End Try
    End Function
End Class
